home *** CD-ROM | disk | FTP | other *** search
- /*
- File ResEd.p
-
- Copyright Apple Computer, Inc. 1984-1989
- All rights reserved.
-
- Resource editor interface unit for instances of editors and pickers. This should be
- included by any C implementation of a resource editor or picker. The
- companion file ResDisp.a.o should be linked with the c module to build
- the file for inclusion in ResEdit.
-
- Pickers are given a resource type and should display all of that type in
- the current resfile in a suitable format. If the picker is given an open call
- AND there's a compatible editor, it should give birth to the Editor. The editor
- is given a handle to the resource object and it should open up an edit
- window for the user.
-
- Note that anybody can open pickers and editors so, for instance, a dialog item list
- editor might open an icon Picker for the user to choose an appropriate icon.
- The user could also, while in the icon picker, open the icon editor to create
- a new icon if desired.
-
- */
-
- #include <types.h>
- #include <quickdraw.h>
- #include <lists.h>
- #include <controls.h>
- #include <windows.h>
- #include <events.h>
- #include <dialogs.h>
-
- /* Standard menus exported by ResEdit */
-
- #define fileMenu 2
-
- #define newItem 1
- #define openItem 2
- #define openAsItem 3
- #define opnOther 3
- #define openGeneralItem 4
- #define opnGnrl 4
-
- #define closeItem 6
- #define saveItem 7
- #define revertItem 8
- #define getInfoItem 9
- #define preferencesItem 10
- #define transferItem 12
- #define quitItem 13
-
- /* Masks for AbleMenu - normally not used directly. */
- #define newMask 2
- #define openMask 4
- #define openAsMask 8
- #define openGnrlMask 0x10
- #define closeMask 0x40
- #define saveMask 0x80
- #define revertMask 0x100
- #define getInfoMask 0x200
- #define preferencesMask 0x400
- #define transferMask 0x1000
- #define quitMask 0x2000
- #define disabledMask 0xFFFFC001
-
- /* Mask combinations to be used in calls to AbleMenu. */
- #define fileQuit disabledMask + preferencesMask + transferMask + quitMask
- #define fileClose fileQuit + closeMask + saveMask
- #define fileAll fileClose + newMask + openMask + openAsMask + openGnrlMask + revertMask + getInfoMask
- #define fileNoRevert fileAll - revertMask
- #define fileNoInfo fileAll - getInfoMask
- #define fileNoNew fileAll - newMask
- #define fileNoOpen fileClose + newMask + revertMask + getInfoMask
- #define fileNoNewOrOpen fileNoOpen - newMask
- #define fileTop fileClose + revertMask + getInfoMask
- #define fileOpQuOnly fileQuit + openMask + openAsMask + openGnrlMask
- #define fileROMStuff fileQuit + openMask + openAsMask + openGnrlMask + closeMask + getInfoMask
- #define fileDiskStuff fileQuit + newMask + openMask + closeMask + getInfoMask
-
- #define editMenu 3
-
- #define undoItem 1
- #define cutItem 3
- #define copyItem 4
- #define pasteItem 5
- #define clearItem 6
- #define dupItem 8
-
- /* Masks for AbleMenu - normally not used directly. */
- #define undoMask 0x2
- #define cutMask 0x8
- #define editCopyMask 0x10
- #define pasteMask 0x20
- #define clearMask 0x40
- #define duplicateMask 0x100
- #define editDisabledMask 0xFFFFFE01
-
- /* Mask combinations to be used in calls to AbleMenu. */
- #define editNone editDisabledMask
- #define editClear editNone + clearMask
- #define editCopy editNone + editCopyMask
- #define editPaste editNone + pasteMask
- #define editUndoPasteOnly editPaste + undoMask
- #define editDup editClear + duplicateMask
- #define editNoDup editNone + cutMask + editCopyMask + pasteMask + clearMask /* No dup or undo */
- #define editNoUndo editNoDup + duplicateMask
- #define editUndNoDup editNoDup + undoMask
- #define editAll editNoUndo + undoMask
- #define editAcc editUndNoDup
-
- #define editorNameChr 0 /* First char of the name for editors */
-
- /* Standard strings available by calling GetStr. */
- #define editStrings 130 /* Resource ID of STR# resource containing the strings. */
- #define undoChangeStr 1
- #define redoChangeStr 2
- #define undoCutStr 3
- #define redoCutStr 4
- #define undoCopyStr 5
- #define redoCopyStr 6
- #define undoClearStr 7
- #define redoClearStr 8
- #define undoTypingStr 9
- #define redoTypingStr 10
- #define undoPasteStr 11
- #define redoPasteStr 12
- #define undoStr 13
-
- #define miscStrings 129 /* Resource ID of STR# resource containing the strings. */
- #define fromStr 1 /* String for window titles. */
- #define fullWindowStr 38 /* String for the resizeWind menu item */
- #define ownerWindowWindowStr 39
- #define newItemStr 40 /* Enter new item number */
- #define selectItemStr 41 /* Open which item? */
- #define clipBoardErrorStr 42 /* Error accessing the Clipboard. */
- #define sndErrorStr 43 /* Error playing a sound. */
- #define openAsDotStr 44 /* Open As ... */
- #define openAsDITMStr 45 /* Open As Dialog Item */
-
- #define arrowCursor -1 /* Used in the call to SetTheCursor to set the arrow cursor. */
-
- #define minPickStdWidth 150
- #define minPickStdRows 4
-
- #define okChoice 1
-
- #define revertResourceAlert 1387 /* Used by all editors to when revert is selected. */
-
- /* Alert kinds used by the DisplayAlert procedure. */
- #define displayTheAlert 0
- #define displayStopAlert 1
- #define displayNoteAlert 2
- #define displayCautionAlert 3
-
- typedef unsigned char Str64[65];
-
- /* map entry definition for new resource manager call */
- typedef struct {
- short rID;
- short rNameOff;
- long rLocn;
- Handle rHndl;
- } ResMapEntry;
-
- /* This structure is used by the GetQuickDrawVars procedure. */
- typedef struct {
- long randSeed;
- BitMap screenBits;
- Cursor arrow;
- Pattern dkGray;
- Pattern ltGray;
- Pattern gray;
- Pattern black;
- Pattern white;
- GrafPtr thePort;
- } QuickDrawVars;
- typedef QuickDrawVars *pQuickDrawVars;
-
- /* Each driver has its own object handle. This has to start with a handle
- to its parent's object followed by the name distinguishing the father
- This name will be part of the son's window title. The next field should
- be the window of the obj (may be used by son to get back to the father
- (through the refcon in the windowRec). The next field is the rebuild flag
- used to indicate that a windows data (e.g. a pickers list) needs to be
- recalculated at the next opportunity. The rest of the handle can be of
- any format. The name for pickers should be the name of the file or disk.
- For editors, the name should be the complete name (not the windows title)
- preceded by an editorNameChr character (see const above). An example of a
- complete name would be "ALRT ID = -1234 from AFile". This name is used to
- uniquely identify a window.
-
- See the manual for detailed documentation of this interface file. */
-
- typedef struct ParentRec {
- struct ParentRec **father;
- Str64 name; /* Max 64 characters */
- WindowPeek wind;
- Boolean rebuild; /* flag set by son to indicate that world */
- /* has changed so father should rebuild list */
- } ParentRec;
-
- typedef ParentRec *ParentPtr;
- typedef ParentPtr *ParentHandle;
-
- /* Standard picker record */
-
- typedef struct PickRec {
- ParentHandle father; /* Back ptr to dad */
- Str64 fName; /* Max 64 characters. */
- WindowPtr wind; /* Directory window */
- Boolean rebuild;
- short pickID; /* ID of this picker */
- ResType rType; /* Type for this picker */
- short rNum; /* resfile number */
- long rSize; /* size of a null resource */
- short nInsts; /* Number of instances */
- ListHandle instances; /* List of instances */
- Ptr drawProc; /* List draw proc */
- ControlHandle scroll; /* Scroll bar */
- } PickRec;
-
- typedef PickRec *PickPtr;
- typedef PickPtr *PickHandle;
-
-
- /* These routines are used to start pickers and editors.*/
-
- pascal void GiveEBirth(Handle resHandle, PickHandle pick);
- pascal void GiveThisEBirth(Handle resHandle, PickHandle pick, ResType openThisType);
- pascal void GiveSubEBirth(Handle resHandle, PickHandle pick);
-
- /* These routines are used to feed events and menu calls to the appropriate picker or editor. */
-
- pascal void CallInfoUpdate(short oldID, short newID, long object, short id);
- pascal void PassMenu(short menu, short item, ParentHandle father);
-
- /* Window Utilities */
-
- pascal Boolean AlreadyOpen (StringPtr windowTitle, StringPtr windowName, ParentHandle father);
- pascal WindowPtr CWindSetup (short width, short height, StringPtr t, StringPtr s);
- pascal WindowPtr EditorWindSetup (Boolean color, short width, short height, StringPtr windowTitle,
- StringPtr windowName, Boolean addFrom, ParentHandle father);
- pascal void GetWindowTitle (StringPtr windowTitle, StringPtr windowName, Boolean addFrom,
- ParentHandle father);
- pascal void SetETitle(Handle h, StringPtr str);
- pascal WindowPtr WindAlloc(void);
- pascal void WindReturn(WindowPtr w);
- pascal ListHandle WindList(WindowPtr w, short nAcross, Point cSize, short drawProc);
- pascal void WindOrigin(WindowPtr);
- pascal WindowPtr WindSetup(short width, short height, StringPtr t, StringPtr s);
-
-
- /* Extended Resource Manager */
-
- pascal short CurrentRes(void);
- pascal Handle Get1Index(ResType, short index);
- pascal Handle Get1Res(ResType, short id);
- pascal Boolean NeedToRevert (WindowPtr myWindow, Handle theRes);
- pascal void RemoveResource (Handle theRes);
- pascal Boolean RevertThisResource (ParentHandle theObj, Handle theRes);
- pascal short SysResFile(void);
-
- /* Miscellaneous utilities */
-
- pascal void Abort(void);
- pascal void AbleMenu(short menu, long enable);
- pascal Boolean AddNewRes(Handle hNew, ResType t, short idNew, StringPtr s);
- pascal void BubbleUp(Handle);
- pascal short BuildType(ResType t, ListHandle l);
- pascal Boolean CheckError(short err, short msgID);
- pascal Boolean CloseNoSave(void);
- pascal void ConcatStr(StringPtr str1, StringPtr str2);
- pascal short DefaultListCellSize(void);
- pascal short DisplayAlert(short which, short id);
- pascal void FixHand(long s, Handle h);
- pascal void FlashDialogItem (DialogPtr dp, short item);
- pascal void FrameDialogItem (DialogPtr dp, short item);
- pascal pQuickDrawVars GetQuickDrawVars(void);
- pascal void GetStr(short num, short list, StringPtr str);
- pascal void GrowMyWindow (short minWidth, short minHeight, WindowPtr windPtr, ListHandle);
- pascal Boolean HandleCheck(Handle h, short msgID);
- pascal void MetaKeys(short *cmd, short *shift, short *opt);
- pascal Handle NewRes(long s, ResType t, ListHandle l, short *n);
- pascal void PickEvent(EventRecord *evt, PickHandle pick);
- pascal void PickInfoUp(short oldID, short newID, PickHandle pick);
- pascal void PickMenu(short menu, short item, PickHandle pick);
- pascal short PickStdRows(void);
- pascal short PickStdWidth(void);
- pascal short ResEdID(void);
- pascal void SendRebuildToPickerAndFile (ResType theType, ParentHandle parent) ;
- pascal void SetResChanged(Handle h);
- pascal void SetTheCursor (short whichCursor);
- pascal void ShowInfo(Handle h, ParentHandle father);
- pascal void TypeToString(ResType t, StringPtr s);
- pascal void UseAppRes(void) =
- { 0x3f38, 0x0900, /* move.w CurApRefNum,-(sp) */
- 0xa998 }; /* _UseResFile */
- pascal Boolean WasAborted(void);
-
- /* Routines that are used internally withing ResEdit and may be useful in other
- circumstances. */
-
- pascal void CallEBirth(Handle thing, ParentHandle parent, short id);
- pascal void CallEvent(EventRecord *evt, long object, short id);
- pascal void CallMenu(short menu, short item, long object, short id);
- pascal void CallPBirth(ResType t, ParentHandle parent, short id);
- pascal Handle CopyRes(Handle *h, Boolean makeID, short resNew);
- pascal void DoKeyScan(EventRecord *evt, short offset, ListHandle lh);
- pascal void DoListEvt(EventRecord e, ListHandle l);
- pascal Handle DupPick(Handle h, Cell c, PickHandle pick);
- pascal Boolean GetType(Boolean templatesOnly, StringPtr s);
- pascal void KillCache(void);
- pascal void RCalcMask(Ptr srcPtr, Ptr dstPtr,
- short srcRow, short dstRow, short height, short words);
- pascal short ResEditRes(void) =
- {0x3eB8, 0x0900}; /* move.w CurApRefNum,(sp) */
- pascal void ScrapCopy(Handle *h);
- pascal void ScrapEmpty(void);
- pascal void ScrapPaste(Boolean pasteAll, ResType typeToPaste, short resFile);
-
- /* Obsolete routines that are left in for compatability. */
-
- pascal Boolean RevertResource(Handle);
-
-